import * as homeApi from './service';

export default {
  namespace: 'home',
  state: {
    banner: [],
    brands: [],
    products_list: [],
    name: '123123',
    page: 1,
  },
  effects: {
    // * load(_, {call, put}) {
    //   const { status, data } = yield call(homeApi.homepage, {});
    //   if (status === 'ok') {
    //     yield put({ type: 'save',payload: {
    //       banner: data.banner,
    //       brands: data.brands
    //     } });
    //   }
    // },
    // * product(_, {call, put, select}) {
    //   const { page, products_list } = yield select(state => state.home);
    //   const { status, data } = yield call(homeApi.product, {
    //     page,
    //     mode: 1,
    //     type: 0,
    //     filter: 'sort:recomm|c:330602',
    //   });
    //   if (status === 'ok') {
    //     yield put({ type: 'save',payload: {
    //       products_list: page > 1 ? [...products_list,...data.rows] : data.rows,
    //     } });
    //   }
    // },
    * load(_, {put}) {
      yield put({ type: 'save',payload: {
        banner: [{
          image_src: 'https://img.yzcdn.cn/upload_files/2018/11/10/FsnFx1QnCr8uWFY_QJNbTks_OP-9.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg'
        },{
          image_src: 'https://img.yzcdn.cn/upload_files/2018/12/14/FpfM3ju6uu6I1L9qO9W1_zX3Bog5.jpeg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpeg'
        }],
        brands: [{
          images: [{
            src: 'https://img.yzcdn.cn/upload_files/2018/11/10/FkJs-qZbFEnBTxk7_gQJpbecSgyn.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg'
          }],
        },{
          images: [{
            src: 'https://img.yzcdn.cn/upload_files/2018/11/10/Ft92K49WZzSsFinR-DwGJ9ptu0tT.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg'
          }],
        }, {
          images: [{
            src: 'https://img.yzcdn.cn/upload_files/2018/11/10/FogYchZDbgzsq7vAsQBzMwLM32DC.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg'
          }],
        },{
          images: [{
            src: 'https://img.yzcdn.cn/upload_files/2018/11/10/FvZweVN2ZR5GtqVB412c81XmKQP6.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg'
          },{
            src: 'https://img.yzcdn.cn/upload_files/2018/11/10/FiESt6RxR9flxYQa46Syuhps481V.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg'
          }],
        }]
      } });
    },
    * product(_, {put}) {
      yield put({
        type: 'save',
        payload: {
          products_list: [{
            title_image: 'https://img.yzcdn.cn/upload_files/2018/11/10/FkYFR_rf5vOf7sja-IuIipVqYbp4.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg',
            content_image: 'https://img.yzcdn.cn/upload_files/2018/11/10/FkovvVeOvCTDQXAKYYugygISAK_O.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg',
            links: [
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv',
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv',
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv',
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv'
            ]
          },{
            title_image: 'https://img.yzcdn.cn/upload_files/2018/11/10/FkYFR_rf5vOf7sja-IuIipVqYbp4.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg',
            content_image: 'https://img.yzcdn.cn/upload_files/2018/11/10/FtO0WkIcnk9alF7d4QkIT-K5TCB5.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg',
            links: [
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv',
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv'
            ]
          },{
            title_image: 'https://img.yzcdn.cn/upload_files/2018/11/10/FkYFR_rf5vOf7sja-IuIipVqYbp4.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg',
            content_image: 'https://img.yzcdn.cn/upload_files/2018/11/10/FnkcMI6Zue8ocoVrGSGJVzRaB2jH.jpg?imageView2%2F2%2Fw%2F730%2Fh%2F0%2Fq%2F75%2Fformat%2Fjpg',
            links: [
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv',
              'https://h5.youzan.com/v2/showcase/goods?alias=3nfe8qt9511lv'
            ]
          }]
        }
      })
    }
  },
  reducers: {
    save(state, { payload }) {
      return {...state, ...payload};
    },
  },
};